package com.sctu.adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by zhengsenwen on 2015/12/10.
 */
public class FoodAdapter extends PagerAdapter {

    private List<ImageView> imageViewsList;

    public FoodAdapter(List<ImageView> imageViewList) {
        this.imageViewsList = imageViewList;
    }

    @Override
    public int getCount() {
        return imageViewsList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ((ViewPager) container).addView(imageViewsList.get(position));
        return imageViewsList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        ((ViewPager) container).removeView(imageViewsList.get(position));
    }
}
